from PyQt4.QtCore import QTimer
from PyQt4.QtGui import QWidget, QLabel, QPixmap
from .led_lamp import LEDLamp

class LEDBar(QWidget):
	def __init__(self, *args, **kw):
		QWidget.__init__(self, *args, **kw)
		self.setGeometry(0,0, 217,30)

		self.leds = []

		pic = QLabel(self)
		path = "work/lightbar.png"
		pic.setPixmap(QPixmap(path))
		pic.setGeometry(0, 0, 217,30)

		x = 4
		for i in range(8):
			l = LEDLamp(self)
			l.setGeometry(x,9,18,12)
			self.leds.append(l)
			x += 27

		self.timer = QTimer(self);
		self.timer.timeout.connect(self.idle)
		self.timer.start(200);

	def idle(self):
		for led in self.leds:
			led.check()

	def randomise(self):
		for led in self.leds:
			led.randomise()

#
# this is the frame around the picture on the main screen
#
# it's a complex widget with a lot of stuff going on
#

